package org.wattdepot.cli.command;

import org.junit.Before;
import org.wattdepot.client.WattDepotClient;
import static org.junit.Assert.fail;

/**
 * Abstract test class that should be implemented by all WattDepotCliCommand tests.
 * 
 * @author George Lee
 *
 */
public abstract class CommandTestBed {

  /** The host uri to the WattDepot instance.*/
  private String hostUri = "http://server.wattdepot.org:8182/wattdepot/";
  /** The instance of the WattDepot client.*/
  protected WattDepotClient client;
  
  /**
   * Sets up the test for the implementing classes.
   */
  @Before
  public void setup() {
    this.client = new WattDepotClient(this.hostUri);
    // Stop right away if we cannot contact server.
    if (!client.isHealthy()) {
      System.out.println("Failed to connect to " + client.getWattDepotUri());
      fail("Could not instantiate client.");
    }
  }
  
  /**
   * Must be implemented to test the command.
   */
  public abstract void testDoCommand();
}
